home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** File: DoEvent.c
- ** Written by: Eric Soldan
- **
- ** Copyright © 1990-1992 Apple Computer, Inc.
- ** All rights reserved.
- */
-
-
-
- /*****************************************************************************/
-
-
-
- #include "App.h" /* Get the application includes/typedefs, etc. */
- #include "App.Common.h" /* Get the stuff in common with rez. */
- #include "App.protos.h" /* Get the prototypes for the application. */
-
- #ifndef __DESK__
- #include <Desk.h>
- #endif
-
- #ifndef __DISKINIT__
- #include <DiskInit.h>
- #endif
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- #ifndef __MENUS__
- #include <Menus.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __UTILITIES__
- #include "Utilities.h"
- #endif
-
-
-
- /*****************************************************************************/
-
-
-
- extern CursPtr gCursorPtr;
- /* See the file Window2.c for comments about this global. */
-
-
-
- /*****************************************************************************/
- /*****************************************************************************/
-
-
-
- /* Do the right thing for an event. Determine what kind of event it is, and
- ** call the appropriate routines. */
-
- #pragma segment Main
- void DoEvent(EventRecord *event)
- {
- Point pt;
- OSErr err;
- TEHandle teHndl;
-
- switch(event->what) {
-
- case nullEvent:
- DoIdleTasks(event);
- break;
-
- case mouseDown:
- DoMouseDown(event);
- break;
-
- case autoKey:
- case keyDown:
- DoKeyDown(event);
- break;
-
- case activateEvt:
- gCursorPtr = nil; /* Force recalculation of the cursor. */
- DoActivate((WindowPtr)event->message);
- break;
-
- case updateEvt:
- DoUpdate((WindowPtr)event->message);
- break;
-
- case kHighLevelEvent:
- gCursorPtr = nil; /* Force recalculation of the cursor. */
- DoHighLevelEvent(event);
- break;
-
- case osEvt:
- gCursorPtr = nil; /* Force recalculation of the cursor. */
- switch ((event->message >> 24) & 0xFF) {
- /* Must logical and with 0xFF to get only low byte. */
- /* High byte of message. */
-
- case mouseMovedMessage:
- break;
-
- case suspendResumeMessage:
- /* Suspend/resume is also an activate/deactivate. */
- gInBackground = !((event->message) & resumeFlag);
- #if VH_VERSION
- CTEConvertClipboard((event->message) & convertClipboardFlag, !gInBackground);
- #endif
- DoActivate(FrontWindow());
- HiliteWindows();
- break;
- }
- break;
-
- case diskEvt:
- gCursorPtr = nil; /* Force recalculation of the cursor. */
- if (HiWord(event->message) != noErr) {
- SetPt(&pt, kDILeft, kDITop);
- err = DIBadMount(pt, event->message);
- }
- break; /* It is not a bad idea to at least call DIBadMount
- ** in response to a diskEvt, so that the user can
- ** format a floppy. */
- }
-
- DoCursor();
- DoAdjustMenus();
-
- if (teHndl = CTEFindActive(nil)) {
- BeginContent((*teHndl)->inPort);
- CTEIdle();
- EndContent((*teHndl)->inPort);
- }
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* This is called when a window is activated or deactivated. */
-
- #pragma segment Main
- void DoActivate(WindowPtr window)
- {
- NotifyCancel();
-
- if (!IsDAWindow(window)) {
- SetPort(window);
- DoCtlActivate(window);
- DoDrawFrame(window); /* Redraw window scrollbars and growIcon, if any. */
- BeginContent(window);
- DoDrawControls(window, true); /* Redraw content scrollbars. */
- EndContent(window);
- }
- }
-
-
-
-